<template>
    <div v-if="showOverlay" class="overlay" @click.self="closeOverlay">
        <div class="imgBox">
            <!-- 右上角关闭按钮 -->
            <div class="close-button" @click="closeOverlay"><img style="height: 100%;width: 100%;"
                    src="@/assets/close.png" alt=""></div>

            <!-- 全屏图片展示 -->
            <img :src="imageSrc" alt="fullscreen image" class="overlay-image" />
            <span class="title">{{ title }}</span>
        </div>
    </div>
</template>

<script>
import { defineComponent } from "vue";

export default defineComponent({
    props: {
        imageSrc: {
            type: String,
            required: true,
        },
        showOverlay: {
            type: Boolean,
            default: false,
        },
        title: {
            type: String,
            required: true,
        }
    },
    emits: ["close"],
    setup(props, { emit }) {
        const closeOverlay = () => {
            emit("close");
        };

        return {
            closeOverlay,
        };
    },
});
</script>

<style scoped>
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.imgBox {
    position: relative;
    width: 800px;
    /* height: 800px; */
    display: flex;
    flex-direction: column;
    /* 将主轴设置为垂直方向 */
    align-items: center;
}

.title {
    color: white;
    margin-top: 10px;

}

.overlay-image {
    width: 100%;
}

/* 关闭按钮样式 */
.close-button {
    position: absolute;
    top: -40px;
    right: -40px;
    background: none;
    border: none;
    font-size: 24px;
    background-color: white;
    cursor: pointer;
    z-index: 1001;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    /* 确保按钮显示在图片上方 */
}
</style>